package com.hsh.server.project.user.controller;

import java.util.List;

import com.hsh.server.common.controller.BaseController;
import com.hsh.server.project.user.entity.TAppCertificate;
import com.hsh.server.project.user.service.ITAppCertificateService;
import com.hsh.server.util.R;
import com.hsh.server.util.page.TableDataInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

/**
 * 我的证件Controller
 * 
 * @author administrator
 * @date 2025-04-20
 */
@RestController
@RequestMapping("/system/certificate")
public class TAppCertificateController extends BaseController
{
    private String prefix = "system/certificate";

    @Autowired
    private ITAppCertificateService tAppCertificateService;

    @GetMapping()
    public String certificate()
    {
        return prefix + "/certificate";
    }

    /**
     * 查询我的证件列表
     */
    @GetMapping("/list")
    public TableDataInfo list(TAppCertificate tAppCertificate)
    {
        startPage();
        List<TAppCertificate> list = tAppCertificateService.selectTAppCertificateList(tAppCertificate);
        return getDataTable(list);
    }

    /**
     * 新增我的证件
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存我的证件
     */
    @PostMapping("/add")
    public R addSave(@RequestBody TAppCertificate tAppCertificate)
    {
        return R.success(tAppCertificateService.insertTAppCertificate(tAppCertificate));
    }

    /**
     * 修改我的证件
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        TAppCertificate tAppCertificate = tAppCertificateService.selectTAppCertificateById(id);
        mmap.put("tAppCertificate", tAppCertificate);
        return prefix + "/edit";
    }

    /**
     * 修改保存我的证件
     */
    @PostMapping("/edit")
    public R editSave(@RequestBody TAppCertificate tAppCertificate)
    {
        return R.success(tAppCertificateService.updateTAppCertificate(tAppCertificate));
    }

    /**
     * 删除我的证件
     */
    @PostMapping( "/remove")
    public R remove(String ids)
    {
        return R.success(tAppCertificateService.deleteTAppCertificateByIds(ids));
    }
}
